package org.dromara.common.core.validator;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.dromara.common.core.annotation.UserExists;
import org.dromara.common.core.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserExistsValidator implements ConstraintValidator<UserExists, Long> {

    @Autowired
    private UserService userService;

    @Override
    public boolean isValid(Long userId, ConstraintValidatorContext context) {
        return userService.checkUserExist(userId);
    }
}
